<?php
/**********************************************************************
    Copyright (C) FrontAccounting, LLC.
	Released under the terms of the GNU General Public License, GPL, 
	as published by the Free Software Foundation, either version 3 
	of the License, or (at your option) any later version.
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************/
$page_security = 'SA_GLANALYTIC';
// ----------------------------------------------------------------
// $ Revision:	2.0 $
// Creator:	Joe Hunt
// date_:	2005-05-19
// Title:	List of Journal Entries
// ----------------------------------------------------------------
$path_to_root="..";

include_once($path_to_root . "/includes/session.inc");
include_once($path_to_root . "/includes/date_functions.inc");
include_once($path_to_root . "/includes/data_checks.inc");
include_once($path_to_root . "/gl/includes/gl_db.inc");
include_once($path_to_root . "/includes/ui/ui_view.inc");

//----------------------------------------------------------------------------------------------------

print_list_of_journal_entries();

//----------------------------------------------------------------------------------------------------

function print_list_of_journal_entries()
{
    global $path_to_root, $systypes_array;

    //$from = $_POST['PARAM_0'];
//    $to = $_POST['PARAM_1'];
//    $systype = $_POST['PARAM_2'];
//    $comments = $_POST['PARAM_3'];
//	$destination = $_POST['PARAM_4'];
	//if ($destination)
		include_once($path_to_root . "/reporting/includes/excel_report.inc");
//	else
//		include_once($path_to_root . "/reporting/includes/pdf_report.inc");

    $dec = user_price_dec();

    $cols = array(0, 100, 240, 300, 400, 460, 520, 580,590);

    $headers = array('Nama Pelanggan','Reference', "Total Order",'Total Bayar', 'Kekurangan', 'Tanggal','Duedays');

    $aligns = array('left', 'left', 'right', 'right', 'right', 'left','right');

    $params = null; // array( 	
  //  0 => $comments,
//    				    1 => array('text' => _('Period'), 'from' => $from,'to' => $to),
//                    	2 => array('text' => _('Type'), 'from' => 
//						$systype == -1 ? _('All') : $systypes_array[$systype],
//                            'to' => '')
                      //      );

    $rep = new FrontReport('Laporan Pesanan Belum Lunas', "lapblmlunas", user_pagesize());

    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();

   // if ($systype == -1)
//        $systype = null;

    $trans = get_sales_order_belum_lunas(); //get_gl_transactions($from, $to, -1, null, 0, 0, $systype);
    

    $typeno = $type = 0;
    $debit = $credit = 0.0;
    $totdeb = $totcre = 0.0;
    
    
    $total_Trans = $total_bayar = $total_saldo = 0;
    while ($myrow=db_fetch($trans))
    {    	
        $rep->TextCol(0, 1, $myrow['br_name']);
        $rep->TextCol(1, 2, $myrow['reference']);
        $rep->AmountCol(2, 3, $myrow['total'],2);
        $total_Trans += $myrow['total'];
        $rep->AmountCol(3, 4, $myrow['bayar'],2);
        $total_bayar += $myrow['bayar'];
        $rep->AmountCol(4, 5, $myrow['saldo'],2);
        $total_saldo += $myrow['saldo'];
        $rep->DateCol(5, 6, $myrow['ord_date'], true);
        $rep->AmountCol(6, 7, $myrow['dueday']);
        $rep->NewLine();
    }
    $rep->NewLine();
    $rep->TextCol(1, 2, 'TOTAL');
    $rep->AmountCol(2, 3, $total_Trans,2);
    $rep->AmountCol(3, 4, $total_bayar,2);
    $rep->AmountCol(4, 5, $total_saldo,2);
    $rep->NewLine();

    $rep->End();
}

?>